<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="仓库名称" prop="cWhName">
        <el-input
          v-model="queryParams.cWhName"
          placeholder="请输入仓库名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属部门" prop="cDepCode">
        <el-input
          v-model="queryParams.cDepCode"
          placeholder="请输入所属部门"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="仓库地址" prop="cWhAddress">
        <el-input
          v-model="queryParams.cWhAddress"
          placeholder="请输入仓库地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="电话" prop="cWhPhone">
        <el-input
          v-model="queryParams.cWhPhone"
          placeholder="请输入电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人" prop="cWhPerson">
        <el-input
          v-model="queryParams.cWhPerson"
          placeholder="请输入负责人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计价方式" prop="cWhValueStyle">
        <el-input
          v-model="queryParams.cWhValueStyle"
          placeholder="请输入计价方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否货位管理 " prop="bWhPos">
        <el-input
          v-model="queryParams.bWhPos"
          placeholder="请输入是否货位管理 "
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="资金定额" prop="iWhFundQuota">
        <el-input
          v-model="queryParams.iWhFundQuota"
          placeholder="请输入资金定额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="仓库期末处理会计期" prop="cMonth">
        <el-input
          v-model="queryParams.cMonth"
          placeholder="请输入仓库期末处理会计期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注" prop="cWhMemo">
        <el-input
          v-model="queryParams.cWhMemo"
          placeholder="请输入备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否冻结" prop="bFreeze">
        <el-input
          v-model="queryParams.bFreeze"
          placeholder="请输入是否冻结"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="条形码" prop="cBarCode">
        <el-input
          v-model="queryParams.cBarCode"
          placeholder="请输入条形码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否参与MRP运算" prop="bMRP">
        <el-input
          v-model="queryParams.bMRP"
          placeholder="请输入是否参与MRP运算"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否参与ROP计算" prop="bROP">
        <el-input
          v-model="queryParams.bROP"
          placeholder="请输入是否参与ROP计算"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="盘点周期" prop="iFrequency">
        <el-input
          v-model="queryParams.iFrequency"
          placeholder="请输入盘点周期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="盘点周期单位" prop="cFrequency">
        <el-input
          v-model="queryParams.cFrequency"
          placeholder="请输入盘点周期单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="每第几天" prop="iDays">
        <el-input
          v-model="queryParams.iDays"
          placeholder="请输入每第几天"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="上次盘点日期 " prop="dLastDate">
        <el-date-picker clearable
          v-model="queryParams.dLastDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择上次盘点日期 ">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="仓库属性" prop="iWHProperty">
        <el-input
          v-model="queryParams.iWHProperty"
          placeholder="请输入仓库属性"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否门店" prop="bShop">
        <el-input
          v-model="queryParams.bShop"
          placeholder="请输入是否门店"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="控制序列号" prop="bControlSerial">
        <el-input
          v-model="queryParams.bControlSerial"
          placeholder="请输入控制序列号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="记入成本" prop="bInCost">
        <el-input
          v-model="queryParams.bInCost"
          placeholder="请输入记入成本"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="纳入可用量计算" prop="bInAvailCalcu">
        <el-input
          v-model="queryParams.bInAvailCalcu"
          placeholder="请输入纳入可用量计算"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="代管仓" prop="bProxyWh">
        <el-input
          v-model="queryParams.bProxyWh"
          placeholder="请输入代管仓"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="销售可用量控制方式" prop="iSAConMode">
        <el-input
          v-model="queryParams.iSAConMode"
          placeholder="请输入销售可用量控制方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口可用量控制方式" prop="iEXConMode">
        <el-input
          v-model="queryParams.iEXConMode"
          placeholder="请输入出口可用量控制方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库存可用量控制方式" prop="iSTConMode">
        <el-input
          v-model="queryParams.iSTConMode"
          placeholder="请输入库存可用量控制方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否保税仓" prop="bBondedWh">
        <el-input
          v-model="queryParams.bBondedWh"
          placeholder="请输入是否保税仓"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="资产仓" prop="bWhAsset">
        <el-input
          v-model="queryParams.bWhAsset"
          placeholder="请输入资产仓"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="配额(%)" prop="fWhQuota">
        <el-input
          v-model="queryParams.fWhQuota"
          placeholder="请输入配额(%)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="停用日期 " prop="dWhEndDate">
        <el-date-picker clearable
          v-model="queryParams.dWhEndDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择停用日期 ">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="是否核算分项成本" prop="bCheckSubitemCost">
        <el-input
          v-model="queryParams.bCheckSubitemCost"
          placeholder="请输入是否核算分项成本"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="拣货货位 " prop="cPickPos">
        <el-input
          v-model="queryParams.cPickPos"
          placeholder="请输入拣货货位 "
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="电商仓" prop="bEB">
        <el-input
          v-model="queryParams.bEB"
          placeholder="请输入电商仓"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="修改日期" prop="dModifyDate">
        <el-date-picker clearable
          v-model="queryParams.dModifyDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择修改日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="仓库核算组" prop="cWareGroupCode">
        <el-input
          v-model="queryParams.cWareGroupCode"
          placeholder="请输入仓库核算组"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="省/直辖市" prop="cProvince">
        <el-input
          v-model="queryParams.cProvince"
          placeholder="请输入省/直辖市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="市" prop="cCity">
        <el-input
          v-model="queryParams.cCity"
          placeholder="请输入市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区县 " prop="cCounty">
        <el-input
          v-model="queryParams.cCounty"
          placeholder="请输入区县 "
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="cFactoryCode">
        <el-input
          v-model="queryParams.cFactoryCode"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['warehouse:warehouse:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['warehouse:warehouse:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['warehouse:warehouse:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['warehouse:warehouse:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="warehouseList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="仓库名称" align="center" prop="cWhName" />
      <el-table-column label="所属部门" align="center" prop="cDepCode" />
      <el-table-column label="仓库地址" align="center" prop="cWhAddress" />
      <el-table-column label="电话" align="center" prop="cWhPhone" />
      <el-table-column label="负责人" align="center" prop="cWhPerson" />
      <el-table-column label="计价方式" align="center" prop="cWhValueStyle" />
      <el-table-column label="是否货位管理 " align="center" prop="bWhPos" />
      <el-table-column label="资金定额" align="center" prop="iWhFundQuota" />
      <el-table-column label="仓库期末处理会计期" align="center" prop="cMonth" />
      <el-table-column label="备注" align="center" prop="cWhMemo" />
      <el-table-column label="是否冻结" align="center" prop="bFreeze" />
      <el-table-column label="条形码" align="center" prop="cBarCode" />
      <el-table-column label="是否参与MRP运算" align="center" prop="bMRP" />
      <!-- <el-table-column label="时间戳" align="center" prop="pubufts" /> -->
      <el-table-column label="是否参与ROP计算" align="center" prop="bROP" />
      <el-table-column label="盘点周期" align="center" prop="iFrequency" />
      <el-table-column label="盘点周期单位" align="center" prop="cFrequency" />
      <el-table-column label="每第几天" align="center" prop="iDays" />
      <el-table-column label="上次盘点日期 " align="center" prop="dLastDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dLastDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="仓库属性" align="center" prop="iWHProperty" />
      <el-table-column label="是否门店" align="center" prop="bShop" />
      <el-table-column label="控制序列号" align="center" prop="bControlSerial" />
      <el-table-column label="记入成本" align="center" prop="bInCost" />
      <el-table-column label="纳入可用量计算" align="center" prop="bInAvailCalcu" />
      <el-table-column label="代管仓" align="center" prop="bProxyWh" />
      <el-table-column label="销售可用量控制方式" align="center" prop="iSAConMode" />
      <el-table-column label="出口可用量控制方式" align="center" prop="iEXConMode" />
      <el-table-column label="库存可用量控制方式" align="center" prop="iSTConMode" />
      <el-table-column label="是否保税仓" align="center" prop="bBondedWh" />
      <el-table-column label="资产仓" align="center" prop="bWhAsset" />
      <el-table-column label="配额(%)" align="center" prop="fWhQuota" />
      <el-table-column label="停用日期 " align="center" prop="dWhEndDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dWhEndDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否核算分项成本" align="center" prop="bCheckSubitemCost" />
      <el-table-column label="拣货货位 " align="center" prop="cPickPos" />
      <el-table-column label="电商仓" align="center" prop="bEB" />
      <el-table-column label="修改日期" align="center" prop="dModifyDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dModifyDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="仓库核算组" align="center" prop="cWareGroupCode" />
      <el-table-column label="省/直辖市" align="center" prop="cProvince" />
      <el-table-column label="市" align="center" prop="cCity" />
      <el-table-column label="区县 " align="center" prop="cCounty" />
      <el-table-column label="${comment}" align="center" prop="cFactoryCode" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['warehouse:warehouse:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['warehouse:warehouse:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改warehouse对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="仓库编码" prop="cWhCode">
          <el-input v-model="form.cWhCode" placeholder="请输入仓库编码" />
        </el-form-item>
        <el-form-item label="仓库名称" prop="cWhName">
          <el-input v-model="form.cWhName" placeholder="请输入仓库名称" />
        </el-form-item>
        <el-form-item label="所属部门" prop="cDepCode">
          <el-input v-model="form.cDepCode" placeholder="请输入所属部门" />
        </el-form-item>
        <el-form-item label="仓库地址" prop="cWhAddress">
          <el-input v-model="form.cWhAddress" placeholder="请输入仓库地址" />
        </el-form-item>
        <el-form-item label="电话" prop="cWhPhone">
          <el-input v-model="form.cWhPhone" placeholder="请输入电话" />
        </el-form-item>
        <el-form-item label="负责人" prop="cWhPerson">
          <el-input v-model="form.cWhPerson" placeholder="请输入负责人" />
        </el-form-item>
        <el-form-item label="计价方式" prop="cWhValueStyle">
          <el-input v-model="form.cWhValueStyle" placeholder="请输入计价方式" />
        </el-form-item>
        <el-form-item label="是否货位管理 " prop="bWhPos">
          <el-input v-model="form.bWhPos" placeholder="请输入是否货位管理 " />
        </el-form-item>
        <el-form-item label="资金定额" prop="iWhFundQuota">
          <el-input v-model="form.iWhFundQuota" placeholder="请输入资金定额" />
        </el-form-item>
        <el-form-item label="仓库期末处理会计期" prop="cMonth">
          <el-input v-model="form.cMonth" placeholder="请输入仓库期末处理会计期" />
        </el-form-item>
        <el-form-item label="备注" prop="cWhMemo">
          <el-input v-model="form.cWhMemo" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="是否冻结" prop="bFreeze">
          <el-input v-model="form.bFreeze" placeholder="请输入是否冻结" />
        </el-form-item>
        <el-form-item label="条形码" prop="cBarCode">
          <el-input v-model="form.cBarCode" placeholder="请输入条形码" />
        </el-form-item>
        <el-form-item label="是否参与MRP运算" prop="bMRP">
          <el-input v-model="form.bMRP" placeholder="请输入是否参与MRP运算" />
        </el-form-item>
        <el-form-item label="是否参与ROP计算" prop="bROP">
          <el-input v-model="form.bROP" placeholder="请输入是否参与ROP计算" />
        </el-form-item>
        <el-form-item label="盘点周期" prop="iFrequency">
          <el-input v-model="form.iFrequency" placeholder="请输入盘点周期" />
        </el-form-item>
        <el-form-item label="盘点周期单位" prop="cFrequency">
          <el-input v-model="form.cFrequency" placeholder="请输入盘点周期单位" />
        </el-form-item>
        <el-form-item label="每第几天" prop="iDays">
          <el-input v-model="form.iDays" placeholder="请输入每第几天" />
        </el-form-item>
        <el-form-item label="上次盘点日期 " prop="dLastDate">
          <el-date-picker clearable
            v-model="form.dLastDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择上次盘点日期 ">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="仓库属性" prop="iWHProperty">
          <el-input v-model="form.iWHProperty" placeholder="请输入仓库属性" />
        </el-form-item>
        <el-form-item label="是否门店" prop="bShop">
          <el-input v-model="form.bShop" placeholder="请输入是否门店" />
        </el-form-item>
        <el-form-item label="控制序列号" prop="bControlSerial">
          <el-input v-model="form.bControlSerial" placeholder="请输入控制序列号" />
        </el-form-item>
        <el-form-item label="记入成本" prop="bInCost">
          <el-input v-model="form.bInCost" placeholder="请输入记入成本" />
        </el-form-item>
        <el-form-item label="纳入可用量计算" prop="bInAvailCalcu">
          <el-input v-model="form.bInAvailCalcu" placeholder="请输入纳入可用量计算" />
        </el-form-item>
        <el-form-item label="代管仓" prop="bProxyWh">
          <el-input v-model="form.bProxyWh" placeholder="请输入代管仓" />
        </el-form-item>
        <el-form-item label="销售可用量控制方式" prop="iSAConMode">
          <el-input v-model="form.iSAConMode" placeholder="请输入销售可用量控制方式" />
        </el-form-item>
        <el-form-item label="出口可用量控制方式" prop="iEXConMode">
          <el-input v-model="form.iEXConMode" placeholder="请输入出口可用量控制方式" />
        </el-form-item>
        <el-form-item label="库存可用量控制方式" prop="iSTConMode">
          <el-input v-model="form.iSTConMode" placeholder="请输入库存可用量控制方式" />
        </el-form-item>
        <el-form-item label="是否保税仓" prop="bBondedWh">
          <el-input v-model="form.bBondedWh" placeholder="请输入是否保税仓" />
        </el-form-item>
        <el-form-item label="资产仓" prop="bWhAsset">
          <el-input v-model="form.bWhAsset" placeholder="请输入资产仓" />
        </el-form-item>
        <el-form-item label="配额(%)" prop="fWhQuota">
          <el-input v-model="form.fWhQuota" placeholder="请输入配额(%)" />
        </el-form-item>
        <el-form-item label="停用日期 " prop="dWhEndDate">
          <el-date-picker clearable
            v-model="form.dWhEndDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择停用日期 ">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否核算分项成本" prop="bCheckSubitemCost">
          <el-input v-model="form.bCheckSubitemCost" placeholder="请输入是否核算分项成本" />
        </el-form-item>
        <el-form-item label="拣货货位 " prop="cPickPos">
          <el-input v-model="form.cPickPos" placeholder="请输入拣货货位 " />
        </el-form-item>
        <el-form-item label="电商仓" prop="bEB">
          <el-input v-model="form.bEB" placeholder="请输入电商仓" />
        </el-form-item>
        <el-form-item label="修改日期" prop="dModifyDate">
          <el-date-picker clearable
            v-model="form.dModifyDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择修改日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="仓库核算组" prop="cWareGroupCode">
          <el-input v-model="form.cWareGroupCode" placeholder="请输入仓库核算组" />
        </el-form-item>
        <el-form-item label="省/直辖市" prop="cProvince">
          <el-input v-model="form.cProvince" placeholder="请输入省/直辖市" />
        </el-form-item>
        <el-form-item label="市" prop="cCity">
          <el-input v-model="form.cCity" placeholder="请输入市" />
        </el-form-item>
        <el-form-item label="区县 " prop="cCounty">
          <el-input v-model="form.cCounty" placeholder="请输入区县 " />
        </el-form-item>
        <el-form-item label="${comment}" prop="cFactoryCode">
          <el-input v-model="form.cFactoryCode" placeholder="请输入${comment}" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listWarehouse, getWarehouse, delWarehouse, addWarehouse, updateWarehouse } from "@/api/warehouse/warehouse";

export default {
  name: "Warehouse",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // warehouse表格数据
      warehouseList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cWhName: null,
        cDepCode: null,
        cWhAddress: null,
        cWhPhone: null,
        cWhPerson: null,
        cWhValueStyle: null,
        bWhPos: null,
        iWhFundQuota: null,
        cMonth: null,
        cWhMemo: null,
        bFreeze: null,
        cBarCode: null,
        bMRP: null,
        pubufts: null,
        bROP: null,
        iFrequency: null,
        cFrequency: null,
        iDays: null,
        dLastDate: null,
        iWHProperty: null,
        bShop: null,
        bControlSerial: null,
        bInCost: null,
        bInAvailCalcu: null,
        bProxyWh: null,
        iSAConMode: null,
        iEXConMode: null,
        iSTConMode: null,
        bBondedWh: null,
        bWhAsset: null,
        fWhQuota: null,
        dWhEndDate: null,
        bCheckSubitemCost: null,
        cPickPos: null,
        bEB: null,
        dModifyDate: null,
        cWareGroupCode: null,
        cProvince: null,
        cCity: null,
        cCounty: null,
        cFactoryCode: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询warehouse列表 */
    getList() {
      this.loading = true;
      listWarehouse(this.queryParams).then(response => {
        this.warehouseList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        cWhCode: null,
        cWhName: null,
        cDepCode: null,
        cWhAddress: null,
        cWhPhone: null,
        cWhPerson: null,
        cWhValueStyle: null,
        bWhPos: null,
        iWhFundQuota: null,
        cMonth: null,
        cWhMemo: null,
        bFreeze: null,
        cBarCode: null,
        bMRP: null,
        pubufts: null,
        bROP: null,
        iFrequency: null,
        cFrequency: null,
        iDays: null,
        dLastDate: null,
        iWHProperty: null,
        bShop: null,
        bControlSerial: null,
        bInCost: null,
        bInAvailCalcu: null,
        bProxyWh: null,
        iSAConMode: null,
        iEXConMode: null,
        iSTConMode: null,
        bBondedWh: null,
        bWhAsset: null,
        fWhQuota: null,
        dWhEndDate: null,
        bCheckSubitemCost: null,
        cPickPos: null,
        bEB: null,
        dModifyDate: null,
        cWareGroupCode: null,
        cProvince: null,
        cCity: null,
        cCounty: null,
        cFactoryCode: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.cWhCode)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加warehouse";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const cWhCode = row.cWhCode || this.ids
      getWarehouse(cWhCode).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改warehouse";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.cWhCode != null) {
            updateWarehouse(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addWarehouse(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const cWhCodes = row.cWhCode || this.ids;
      this.$modal.confirm('是否确认删除warehouse编号为"' + cWhCodes + '"的数据项？').then(function() {
        return delWarehouse(cWhCodes);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('warehouse/warehouse/export', {
        ...this.queryParams
      }, `warehouse_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
